package com.tfswx.jcyw.dmzc.window;

import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

public final class TpViewDialog extends DialogWrapper {
    private final byte[] tpBytes;

    public TpViewDialog(byte[] tpBytes) {
        super(false);
        this.setTitle("图片查看");
        this.tpBytes = tpBytes;
        this.init();
    }

    @Override
    protected @NotNull JComponent createCenterPanel() {
        ImageIcon tp = new ImageIcon(this.tpBytes);
        JScrollPane jScrollPane = new JScrollPane(new JLabel(tp));
        JScrollBar verticalScrollBar = jScrollPane.getVerticalScrollBar();
        verticalScrollBar.setUnitIncrement(16);
        jScrollPane.setBorder(BorderFactory.createEmptyBorder());
        return jScrollPane;
    }

    @NotNull
    @Override
    protected Action @NotNull [] createActions() {
        Action okAction = this.getOKAction();
        return new Action[]{okAction};
    }
}
